<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE html>
<html>
	<head>
		<link rel="stylesheet" href="<c:url value="css/bootstrap.css" /> " >
		<link rel="stylesheet" href="<c:url value="css/bootstrap-theme.css" /> ">
		<script type="text/javascript" src="<c:url value="js/jquery-2.1.1.js" /> "></script>
		<script type="text/javascript" src="<c:url value="js/bootstrap.js" /> "></script>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>Profile Page</title>
		<script type="text/javascript">
			$(document).ready(function(){
				$(".editToModal").click(function(e){
					e.preventDefault();
					$("#editModal").modal();
				});
			});
		</script>
	</head>
	<body>
		<div class="container">
			 <!-- Static navbar -->
	      <div class="navbar navbar-default" role="navigation">
	        <div class="container-fluid">
	          <div class="navbar-header">
	            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
	              <span class="sr-only">Toggle navigation</span>
	              <span class="icon-bar"></span>
	              <span class="icon-bar"></span>
	              <span class="icon-bar"></span>
	            </button>
	            <a class="navbar-brand" href="index.jsp">JSP Servlet</a>
	          </div>
	          <div class="navbar-collapse collapse">
	            <ul class="nav navbar-nav">
	              <li><a href="index.jsp">Home</a></li>
	              <% if(session.getAttribute("username") != null) { %>
	              <li><a>Welcome <%= session.getAttribute("username") %></a></li>
	              <% } %>
	              <% if(session.getAttribute("username") != null) { %>
	               <li class="active"><a href="<c:url value="/profile" /> ">Profile</a></li>
	              <% } %>
	              <% if(session.getAttribute("username") != null) {
	            	  if(session.getAttribute("username").equals("admin")) {
	              %>
	              <li><a href="<c:url value="/listUser" />">List User</a></li>
	              <% } } %>
	              <li><a href="register.jsp">Register</a></li>
	              <% if(session.getAttribute("username") == null) { %>
	              <li><a href="login.jsp">Login</a></li>
	              <% } %>
	              <% if(session.getAttribute("username") != null) { %>
	              <li><a href="upload.jsp">Upload</a></li>
	              <% } %>
	              <% if(session.getAttribute("username") != null) { %>
	              <li><a href="<c:url value="/download" />">Download</a></li>
	              <% } %>
	              <% if(session.getAttribute("username") != null) { %>
	              <li><a href="<c:url value="/history" />">Your History</a></li>
	              <% } %>
	              <% if(session.getAttribute("username") != null) { %>
	              <li><a href="<c:url value="/logoutServlet" />">Logout</a></li>
	              <% } %>
	            </ul>
	          </div><!--/.nav-collapse -->
	        </div><!--/.container-fluid -->
	      </div>
	      <div class="bs-callout bs-callout-info">
			  <h4>This is your information</h4>
			  You can edit information here.
		  </div>
		  
		  <c:if test="${not empty messageEdit}">
			    <div class="alert alert-danger">${messageEdit}</div>
		  </c:if>
		  
		  <table class="table table-striped table-bordered table-hover">
		  	<tr>
		  		<th>Username</th>
		  		<th>Password</th>
		  		<th>Change Password</th>
		  	</tr>
		  	<tr>
	  			<tr>
	  				<td>${userprofile.username}</td>
	  				<td>${userprofile.password}</td>
	  				<td><a class="btn btn-warning editToModal"><span class="glyphicon glyphicon-cog"></span> Change</a></td>
	  			</tr>
		  	</tr>
		  </table>
		  
		  <form class="form-horizontal" role="form" action="edituser" method="post">
		  	<!-- Modal -->
			<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			  <div class="modal-dialog modal-lg">
			    <div class="modal-content">
			      <div class="modal-header">
			        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
			        <h4 class="modal-title" id="myModalLabel">Insert New Password</h4>
			      </div>
			      <div class="modal-body">
			      	<div class="form-group">
					    <div class="col-sm-10">
					      <input type="hidden" class="form-control" name="inputName" id="inputName" value="${userprofile.username}">
					    </div>
					  </div>
					  <div class="form-group">
					    <div class="col-sm-10">
					      <input type="hidden" class="form-control" name="inputPage" id="inputPage" value="profile.jsp">
					    </div>
					  </div>
			       	 <div class="form-group">
					    <label for="inputPassword" class="col-sm-3 control-label">New Password</label>
					    <div class="col-sm-9">
					      <input type="password" class="form-control" name="inputPassword" id="inputPassword" placeholder="New Password">
					    </div>
					  </div>
					  <div class="form-group">
					    <label for="inputNewPassword" class="col-sm-3 control-label">Repeat New Password</label>
					    <div class="col-sm-9">
					      <input type="password" class="form-control" name="inputNewPassword" id="inputNewPassword" placeholder="New Password">
					    </div>
					  </div>
			      </div>
			      <div class="modal-footer">
			        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
			        <input value="submit" type="submit" class="btn btn-primary editOfModal">
			      </div>
			    </div>
			  </div>
			</div>
		  </form>
		  <div class="container">
				<div class="navbar navbar-default navbar-fixed-bottom">
		 		<div  class="container">
		        <p class="navbar-text">&copy; Hai Nguyen| Java Fresher</p>
		        <a href="#" class="navbar-btn  btn btn-danger pull-right"><span class="glyphicon glyphicon-chevron-up"></span> Back To Top</a>
		 		</div>
				</div>
			</div>
    </div> <!-- End Container -->
	</body>
</html>